package com.supreme.uploadserver.component.props;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioProps {

    /**
     * http if ture
     * otherwise https
     */
    private Boolean secure;

    /**
     * minio地址
     */
    private String host;

    /**
     * minio端口号
     */
    private int port;

    /**
     * minio用户名
     */
    private String accessKey;

    /**
     * minio密码
     */
    private String secretKey;

    /**
     * 文件桶的名称
     */
    private String bucketName;

    public String fileUrl(String fileName) {
        return String.format("%s://%s:%s/%s/%s", secure ? "https" : "http", host, port, bucketName, fileName);
    }
}
